<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function func(num) {
            return function () {
                // #1
                console.log(num)
            };
        }
        setTimeout(func(1));
        async function async3() {
            // # 这里调用 async4 确实直接打印了 5，但同时产生一个微任务
            await async4();
            // #2
            console.log(8);
        }
        async function async4() {
            console.log(5)
        }
        // !只要调马上就会执行
        async3();
        function func2() {
            // #3
            console.log(2);
            async function async1() {
                await async2();
                // #6
                console.log(9)
            }
            async function async2() {
                console.log(5)
            }
            async1();
            setTimeout(func(4))
        }
        setTimeout(func2);
        setTimeout(func(3));
        new Promise(resolve => {
            console.log('Promise');
            resolve()
        })
            .then(() => console.log(6)) // #4
            .then(() => console.log(7)); // #5
        console.log(0);
    </script>
</body>

</html>